<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<!-- 新 Bootstrap 核心 CSS 文件 -->
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
 
<!-- 可选的Bootstrap主题文件（一般不使用） -->
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"></script>
 
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
 
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 

 <script type="text/javascript">
$(function(){
	 $.ajax({
			url:"/focus/authority",
			type:"get",
			data:{},
			success:function(d){
				//alert("ok")
				if(d['status']==500){
					alert(d['data']);
				}
				if(d['status']==200){
					show(d['data']);
				}
			},
			error:function(){},
			dataType:"json"
		});
	 
	 function show(data){
		// alert("ok")
		 $.each(data,function (i,j){
			
			$("#controller").append("<li id='li"+i+"' role='presentation'>"+j['controller']+"</li>");
			
			$("#li"+i).click(function(){
				showAuthority(j['authorityList']);
			});
		 });
	 }
	 
	 function showAuthority(list){
		 $("#authority").children().remove()
		 $.each(list,function (i,j){
			$("#authority").append("<tr><td>"+j['name']+"</td>"+
									"<td>"+j['code']+"</td>"+
									"<td>"+j['url']+"</td>"+
									"<td>"+j['method']+"</td>"+
									"<td>"+j['des']+"</td>"+
									"</tr>");
		 });
	 }
	 
});
</script>
</head>
<body>
<div class="dropdown">
    <button type="button" class="btn dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown">请选择 Controller
        <span class="caret"></span>
    </button>
    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1" id="controller">
    </ul>
</div>

<div class="container-fluid">
	<div class="row-fluid">
		<div class="span12">
			<table class="table">
				<thead>
					<tr>
						<th>
							名称
						</th>
						<th>
							code
						</th>
						<th>
							URL
						</th>
						<th>
							请求method
						</th>
						<th>
							描述
						</th>
					</tr>
				</thead>
				<tbody id="authority">
				</tbody>
			</table>
		</div>
	</div>
</div>
</body>
</html>